<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!-- 4、使用定时器函数和Date对象实现，数字时钟（当前时间是：2019-06-06 18:40:52）-->
    <div id="mycolock"></div>
    <script>
        function colock(){
            var today=new Date();
            var YY=today.getFullYear();
            var MM=today.getMonth();
            var DD=today.getDay();
            var hh=today.getHours();
            var mm=today.getMinutes();
            var ss=today.getSeconds();
            document.getElementById("mycolock").innerHTML="当前时间是："+YY+"-"+MM+"-"+DD+"&nbsp"+hh+":"+mm+":"+ss;
        }
        var mytime=setInterval("colock()",1000);
    </script>
</body>
</html>